<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="utf-8" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="../common.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>QUẢN LÝ DANH SÁCH DỊCH VỤ</title>
<style type="text/css">
#a {
	color: blue;
	background-color: #FF9A00;
	display: block;
	text-decoration: none;
	font-family: cursive;
}

#a:HOVER {
	color: #FFFFFF;
	background-color: #FF4700;
	text-decoration: none;
	display: block;
	font-family: cursive;
}

#a:ACTIVE {
	background-color: #FF4700;
	text-decoration: none;
	display: block;
	font-family: cursive;
}
#a:LANG {
	color: #FFFFFF;
	background-color: #FF4700;
	text-decoration: none;
	display: block;
	font-family: cursive;
}
</style>
</head>
<body>
<script>
function isok()
{
return confirm('Bạn chắc chắn muốn xóa các sản phẩm đã chọn?');
}
</script>
<%
// 	String userid=getVal((String)session.getValue("userid"),"");
// 	if(userid.equals("")|| userid.equals("0") || userid.equals("-1")|| userid.equals("-2")) response.sendRedirect("admin.jsp");
%>
<p align=center><font style="bold" size=20 >QUẢN LÝ DANH SÁCH DỊCH VỤ</font><br></p>
<table width=1024 height=100 align="center">
	<tr>
		<td width=50% align=center><a id="a" href="index.jsp">Trang chủ</a></td>
		<td width=50% align=center><a id="a" href="logout.jsp">Thoát</a></td>
	</tr>
	<tr>
		<td align=center valign="top" colspan=2><form action="add_service.jsp" method="get"><input type="submit" value="Thêm dịch vụ"></form></td>
	</tr>
</table>
<table width=1024 align="center" border="1">
<tr>
	<td width=10%><font color=red>Mã dịch vụ</font></td>
	<td width=27%><font color=red>Tên dịch vụ</font></td>
	<td width=28%><font color=red>Giá</font></td>
	<td width=15%><font color=red>Số lượng</font></td>
	<td width=10%></td>
	<td width=5%></td>
</tr>

<%
	Class.forName("com.mysql.jdbc.Driver");
	Connection con = null;
	Statement smt = null;
	ResultSet rst = null;
	String str = null;
	String service_id = null;
	try {
		String username = "root";
		String password = "Vietyeutam1112";
		String url = "jdbc:mysql://127.0.0.1:3306/ghmotel";
		con = DriverManager.getConnection(url, username, password);
		System.out.println("Da ket noi CSDL");
		smt = con.createStatement();
		rst = smt.executeQuery("select * from service");
		while(rst.next()) {
			service_id = rst.getString("service_id");
			out.println("<form action=edit_service.jsp method=GET>");
			out.println("<td width=10% valign=top>"+service_id+"</td>");
			str = rst.getString("service_name");
			out.println("<td width=27% valign=top>");
			out.println( str + "</td>");
			str = rst.getString("service_price");
			out.println("<td width=28% valign=top>");
			out.println( str + "</td>");
			str = rst.getString("service_number");
			out.println("<td width=15% valign=top>");
			out.println( str + "</a></td>");
			out.println("<td width=10% valign=top align=center>");
			out.println("<form action=edit_product.jsp method=GET>");
			out.println("<input type=hidden name=service_id value='"+service_id+"'>");
			out.println("<input type=submit value='Chỉnh sửa'></form></td>");
			out.println("<td width=5% valign=top align=center>");
			out.println("<form action=sql_service_delete.jsp method=GET onsubmit='return isok();'>");
			out.println("<input type=hidden name=id value='"+service_id+"'>");
			out.println("<input type=submit value='Xóa'></form></td>");
			out.println( "</tr>");
			out.println("</form>");
		}
		con.close();
		System.out.println("Da dong CSDL");
	} catch (Exception e) {}
%>
</table>

</body>
</html>